#coding=utf-8
'''
3.3. Formatting Numbers for Output
用内置函数 format()
'''
x = 1234.56789
# Two decimal places of accuracy
print(format(x, '0.2f'))

# Right justify in 10 chars, one-digit accuracy
print(format(x, '>10.1f'))

# Left justify
print(format(x, '<10.1f'))

# Centered
print(format(x, '^10.1f'))

# Inclusion of thousands separator
print(format(x, ','))

print(format(x, '0,.1f'))


print(format(x, 'e'))
print(format(x, '0.2E'))

print('The value is {:0.2f}'.format(x))

x = 1234.56789
print(format(x, '0.1f'))
print(format(-x,  '0.1f'))

# swap_separators = {ord('.'): ',', ord(','): '.'}
# print(format(x, ',').translate(swap_separators))

print('%0.2f' % x)












